package com.edz.dudumifi.utils;

import android.util.Log;

/**
 * Created by ganshh.gan on 2018/4/13.
 */

public class WebRedirectCtlService extends Thread {
    private static final String TAG = "WebRedirectCtlService";

    @Override
    public void run() {
        try {
            Log.i(TAG, "WebRedirectCtlService start");
            new Thread(new Client()).start();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    private void setWebRedirectCtl() {
        String strReqs, strRtn;
        String p1 = "\"MsgType\":\"WebRedirectCtl\"";
        String p2 = "\"CmdType\":\"EnableRedirect\"";
        String p3 = "\"WebRedirectUrl\":\"http://ceshi.edawtech.com/mifi/api/redirect\"";
        String p4 = "\"AcceptIPList\":\"115.159.130.60;182.254.214.88;182.254.214.64;119.23.26.153\"";
        String p5 = "\"WLanMac\":\"\"";
        String p6 = "\"IPList\":\"\"";

        strReqs = "{" + p1 + "," + p2 + "," + p3 + "," + p4 + "," + p5 + "," + p6 + "}";
        Log.i(TAG, strReqs);
        strRtn = KKTcpClient.Instance().RequestGateway("127.0.0.1", strReqs);
        Log.i(TAG, "重定向 response" + strRtn.trim());
    }

    class Client implements Runnable {
        @Override
        public void run() {
            try {
                setWebRedirectCtl();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
